<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      #app {
        /* color: white; */
        margin: 0 20px;
        position: relative;
      }
      .test {
        height: 200px;
        width: 200px;
        background: #000;
      }
      header {
        position: relative;
        z-index: 800;
        background: #fff;
      }
      h2 {
        background: #fff;
      }
      .shu {
        position: relative;
        z-index: 800;
        cursor: pointer;
        background-color: rgb(7, 202, 40);
      }
      .testAn {
        /* color: white; */
        background-color: rgb(15, 197, 69);
        box-shadow: 0 10px 40px rgba (32, 0, 0, 0.16);
        height: 60vh;
        width: 500px;
        overflow: hidden;
        position: absolute;
        left: 10px;
        top: 0;
        transform: translateY(-500px);
        /* 隐藏元素 */
        visibility: hidden;
        /* transition: 0.5s; */
        transition: opacity 0.3s ease, transform 1s ease, visibility 0.3s ease;
        opacity: 0;
        z-index: 300;
      }
      .testAn1 {
        opacity: 1;
        visibility: visible;
        /* width: 600px; */
        transform: translateY(60px);
      }
      .content {
        position: absolute;
        z-index: 200;
        width: 100%;
        background-color: #333;
        height: 800px;
      }
    </style>
    <div id="app">
      <header>
        <div>订单数:{{counter}}</div>

        <button v-on:click="add">+</button>
        <button @click="sub">-</button>
      </header>

      <div class="shu" @mouseover="mouseOver" @mouseout="mouseOut">鼠标悬浮</div>
      <div
        :class="{'testAn1':mousefloat}"
        class="testAn"
        @mouseover="mouseOver"
        @mouseout="mouseOut"
      >
        <div>测试5555555555555144ffff</div>
      </div>
      <div class="content"></div>
    </div>

    <script src="./js/vue.js"></script>
    <script>
      let app = new Vue({
        el: "#app", //先定义抓取id
        data: {
          counter: 0,
          mousefloat: false,
        },

        methods: {
          mouseOver() {
            console.log("mouseOver");
            this.mousefloat = true;
          },

          mouseOut() {
            this.mousefloat = false;
          },
          add: function () {
            console.log("adddd");

            this.counter++;
          },
          sub: function () {
            if (this.counter > 0) {
              app.counter--;
            }
            if (this.counter == 0) {
              this.counter == 0;
            }
          },
        },
      });
    </script>
  </body>
</html>
